<?php

namespace app\controller\admin;

use app\BaseController;
use app\model\Order;
use app\model\Package;
use app\model\PackageProduct;
use think\response\Json;

class PackBag extends BaseController
{
    public function page(): Json
    {
        return $this->success($this->app->make(Package::class)->pageData());
    }

    public function save(): Json
    {
        if (!$this->request->isPost()) throw new \Exception('请求方式错误', 7001);
        return $this->success($this->app->make(Package::class)->savePack());
    }

    public function detail(): Json
    {
        return $this->success($this->app->make(Package::class)->detail());
    }

    public function product(): Json
    {
        if(!$this->request->isPost()) throw new \Exception("请求方式错误", 7001);
        return $this->success($this->app->make(PackageProduct::class)->addPackData());
    }

    public function delete(): Json
    {
        if(!$this->request->isDelete()) throw new \Exception("请求方式错误", 7001);
        return $this->success($this->app->make(Package::class)->deleteData());
    }

    public function lst()
    {
        return $this->success($this->app->make(Package::class)->lst());
    }

    public function order()
    {
        return $this->success($this->app->make(Order::class)->pageData());
    }
}
